<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .box1 {
        width: 200px;
        height: 200px;
        background-color: cyan;
      }
      .box2 {
        width: 100px;
        height: 100px;
        background-color: pink;
      }
    </style>
  </head>
  <body>
    <div class="box1">
      <div class="box2"></div>
    </div>
    <script>
      //一.over和out来绑定时间: 会在绑定时间的子元素上触发
      /* var box1Ele = document.querySelector(".box1");
      box1Ele.onmouseover = function () {
        console.log("覆盖了");
      };
      box1Ele.onmouseout = function () {
        console.log("离开了");
      }; */

      //二.enter和leave来绑定时间:不会在绑定元素的子元素上触发事件
      var box2Ele = document.querySelector(".box1");
      box2Ele.onmouseenter = function () {
        console.log("进入了");
      };
      box2Ele.onmouseleave = function () {
        console.log("离开了");
      };
    </script>
  </body>
</html>
